package stone;

import stone.parser.ASTree;
import stone.parser.BasicParser;

import java.io.File;
import java.io.FileNotFoundException;
import java.io.FileReader;
import java.io.Reader;

public class ParserRunner {
    public static void main(String[] args) throws ParseException, FileNotFoundException {
        File file=new File("src/stone/test.txt");
        if (!file.exists()){
            System.out.println("file"+file.getAbsolutePath()+" not exit");
            return;
        }
        Reader reader=new FileReader(file);
        Lexer lexer=new Lexer(reader);
        BasicParser bp = new BasicParser();
        while (lexer.peek(0) != Token.EOF) {
            ASTree ast = bp.parse(lexer);
            System.out.println("=> " + ast.toString());
        }
    }
}
